import java.util.Scanner;

public class text1 {
    /*给你一个整数数组 nums 和两个整数 indexDiff 和 valueDiff 。
    找出满足下述条件的下标对 (i, j)：
    i != j,
    abs(i - j) <= indexDiff
    abs(nums[i] - nums[j]) <= valueDiff
    如果存在，返回 true ；否则，返回 false 。
     */
    public static boolean seekaddress(int[]nums,int indexdiff,int valuediff) {
        int n = nums.length;
        for(int i=0;i<n;i++) {
            for(int j=0;j<n;j++) {
                if(i!=j&&Math.abs(nums[i]-nums[j])<=valuediff&&Math.abs(i-j)<=indexdiff)
                    return true;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        int indexdiff=sc.nextInt();
        int valuediff=sc.nextInt();
        boolean flag=seekaddress(nums,indexdiff,valuediff);
        System.out.println(flag);
        sc.close();
    }
}
